package org.bai.algorithm.util;

import java.util.concurrent.ThreadLocalRandom;

public class ArrayUtils {

    /**
     * 构建随机的int数组
     *
     * @param size 元素数目
     * @param range 范围
     * @return 随机数组
     */
    public static int[] buildInt(int size, int range) {
        ThreadLocalRandom current = ThreadLocalRandom.current();
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = current.nextInt(range);
        }
        return array;
    }

    public static int[] buildIncreaseInt(int size) {
        ThreadLocalRandom current = ThreadLocalRandom.current();
        int max = 0;
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = max + current.nextInt(10);
            max = array[i];
        }
        return array;
    }

}
